<%@ page import="com.zhiyou100.www.bbs.entityclass.TableUser" %>
<%@ page import="org.w3c.dom.ls.LSOutput" %>
<%@ page import="com.zhiyou100.www.bbs.dao.TableUserDao" %>
<%@ page import="com.zhiyou100.www.bbs.function.userinfo.GetUserInformation" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.zhiyou100.www.bbs.dao.TableTitleDao" %>
<%@ page import="com.zhiyou100.www.bbs.entityclass.TableTitle" %>
<%@ page import="com.mchange.v2.lang.ObjectUtils" %>
<%@ page import="com.zhiyou100.www.bbs.function.userinfo.DetermineIfUserIsNull" %>
<%--
  Created by IntelliJ IDEA.
  User: yang
  Date: 2020/6/4
  Time: 4:11 下午
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <script src="/bbs/js/jquery.min.js"></script>
    <!-- 导入 jquery    -->
    <script src="/bbs/js/index.js"></script>
    <%--  导入 首页的js文件   --%>
    <link rel="stylesheet" href="/bbs/css/index.css">
    <script src="/bbs/js/time.js"></script>
    <%--    <script src="/bbs/js/topic.js">--%>
    <%--        &lt;%&ndash;  话题js       &ndash;%&gt;--%>
    <%--    </script>--%>
    <title>主页</title>
</head>
<body>

<%
    // 判断是否登陆
    Object user = session.getAttribute("user");
    // 获取 user 属性

    if ((user != null)) {
        // 不等于 null，无操作
        System.out.println(user.toString());
    } else {
        // 等于 null，转发到登陆失败页面
        //没有登陆，跳转到登陆页面
        response.sendRedirect("/bbs/html/loginFailure.html");
    }
%>
<div class="body">
    <div class="lift">
        <div class="userInfo">
            <%
                TableUser one = new GetUserInformation().getOne(user);
                // 获取一个 tableUser
            %>
            <table class="userInfoTable">
                <tr>
                    <td rowspan="2">
                        <img src="<%=one.getUserHeadPortrait()%>" height="150px" width="160px" alt="头像">
                    </td>
                    <td>
                        用户: <%=one.getUserRealName()%> 你好
                    </td>
                </tr>
                <tr>
                    <td>
                        用户名: <%=one.getUserName()%>
                        <br>
                        id: <%=one.getUserId()%>
                        <br>
                        性别: <%=one.getUserGender()%>
                    </td>
                </tr>
                <tr>
                    <td>积分: <%=one.getUserScore()%>
                    </td>
                    <td>等级：<%=one.getUserStatus()%>
                    </td>
                </tr>
            </table>
        </div>
        <div class="starUser">
            <h5>明星用户</h5>
            <%
                out.write("<iframe src=\"/bbs/jsp/starUser.jsp\" class=\"starUserForm\">");
                out.write("</iframe>");
            %>
        </div>
        <div class="starUser">
            <h5>热点话题</h5>
            <iframe src="/bbs/jsp/hotTopic.jsp" class="starUserForm" style="width: 250px;margin-left: 22px"></iframe>
        </div>
    </div>
    <div class="right">
        <div class="right1">
            <div class="logo"></div>
            <div class="message">
                <p>在线人数：<%=request.getSession().getAttribute("loginNumber")%>
                </p>
                <p><a href="/bbs/LoggedOut">退出登陆</a></p>
                <p id="Clock">
                    时间
                </p>
            </div>
        </div>
        <div class="right2">

        </div>
        <div class="right3">
            <div class="topicSearch">
                <form action="/bbs/SearchTheTopic" method="post">
                    <%--  请求提交给 jsp 文件处理                   --%>
                    <label>
                        <input type="text" name="topic" id="topicSearchSubmittedText">
                    </label>
                    <input type="submit" value="话题搜索" id="topicSearchButton">
                    <%--                    <input type="submit" value="关闭话题搜索" id="turnOffTopicSearch">--%>
                </form>
                <input type="button" value="添加话题" id="addTopic"/>


                <form action="/bbs/AddTheTopic" class="addTopicForm" method="post" id="addForm" style="display: none">
                    <%--  添加框，默认为 display:none 隐藏                   --%>
                    <div class="addTopicFormDiv">
                        标题: <input type="text" name="tableHead" class="headline">
                        <br>
                        <br>
                        <textarea id="tbCommentBody" placeholder="请输入内容" name="tbCommentBody"></textarea>

                        <br>
                        <br>
                        <input type="reset" value="重制" style="margin-left: 40px">
                        <input type="submit" value="提交" style="margin-left: 30px" id="addFormSubmit">
                    </div>

                </form>
                <div id="searchBox">
                    <%--搜索框的内容--%>
                    <%
                        Object message = request.getSession().getAttribute("message");
                        // 获取 session 中的 message
                        TableTitleDao tableTitleDao = new TableTitleDao();
                        // 创建 话题 工具类
                        String table = "";
                        // 字符串记录查询结果
                        if (message != null) {
                            // 如果不为空，输出 查询的话题
                            table = tableTitleDao.getTable((ArrayList<TableTitle>) message);

                        } else {
                            // 如果为空，输出所有的话题
                            table = tableTitleDao.getTable(tableTitleDao.getAll());
                        }
                        out.print(table);

                    %>
                </div>
            </div>

        </div>
    </div>
</div>
</body>
</html>
